#include_directories(${CMAKE_SOURCE_DIR}/include algorithms util nn .)

add_definitions(-D_FLANN_VERSION=${FLANN_VERSION})

file(GLOB_RECURSE C_SOURCES flann.cpp)
file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp)
file(GLOB_RECURSE CU_SOURCES *.cu)

add_library(flann_cpp_s STATIC ${CPP_SOURCES})
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
    set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC)
endif()
SET_PROPERTY(TARGET flann_cpp_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC FLANN_USE_CUDA)

INSTALL(
  TARGETS flann_cpp_s
  DESTINATION lib
  EXPORT aliceVision-targets)

INSTALL (
  DIRECTORY .
  DESTINATION ${FLANN_INCLUDE_INSTALL_DIR}
  FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)

#if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
#    add_library(flann_cpp SHARED "")
#    set_target_properties(flann_cpp PROPERTIES LINKER_LANGUAGE CXX)
#    target_link_libraries(flann_cpp -Wl,-whole-archive flann_cpp_s -Wl,-no-whole-archive)
#else()
#    add_library(flann_cpp SHARED ${CPP_SOURCES})
#endif()

#set_target_properties(flann_cpp PROPERTIES
#   VERSION ${FLANN_VERSION}
#   SOVERSION ${FLANN_SOVERSION}
#   DEFINE_SYMBOL FLANN_EXPORTS
#) 

